<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品分类</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-input style="width:30%"
                placeholder="请输入内容">
        <el-button slot="append"
                   icon="el-icon-search"></el-button>
      </el-input>
      <!-- 表格区域 -->
      <el-table border
                stripe
                :data="orders">
        <el-table-column type="index"
                         label="#"></el-table-column>
        <el-table-column prop="order_number"
                         label="订单编号"></el-table-column>
        <el-table-column prop="order_price"
                         label="订单价格"></el-table-column>
        <el-table-column prop="pay_status"
                         label="是否付款">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.pay_status==='1'"
                    type="success">已付款</el-tag>
            <el-tag v-else
                    type="danger">未付款</el-tag>

          </template>
        </el-table-column>
        <el-table-column prop="is_send"
                         label="是否发货"></el-table-column>
        <el-table-column prop="create_time"
                         label="下单时间">
          <template slot-scope="scope">
            {{scope.row.update_time |formatDate}}
          </template>
        </el-table-column>
        <el-table-column width="250"
                         label="操作">
          <template>
            <el-button @click="editAddressDialogVisible=true"
                       icon="el-icon-edit"
                       type="primary"
                       size="mini">修改地址</el-button>
            <el-button @click="showExpressProgress"
                       icon="el-icon-delete"
                       type="success"
                       size="mini">物流进度</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <!-- 修改地址 -->
    <el-dialog title="地址修改"
               :visible.sync="editAddressDialogVisible"
               width="50%">
      <el-form ref="form"
               :model="form"
               label-width="120px">
        <el-form-item label="省市区/县">
          <el-cascader v-model="form.cityValue"
                       :options="cityData"
                       @change="cascaderHandleChange">
          </el-cascader>
        </el-form-item>
        <el-form-item label="详细地址：">
          <el-input></el-input>

        </el-form-item>
      </el-form>
      <span slot="footer"
            class="dialog-footer">
        <el-button @click="editAddressDialogVisible = false">取消</el-button>
        <el-button type="primary"
                   @click="editAddressDialogVisible = false">确定</el-button>
      </span>
    </el-dialog>
    <!-- 物流进度 -->
    <el-dialog title="物流进度"
               :visible.sync="expressProgressDialogVisible"
               width="50%">
      <el-timeline :reverse="false">
        <el-timeline-item v-for="(item,index) in expressList"
                          :key="index"
                          :timestamp="item.time">
          {{item.content}}
        </el-timeline-item>
      </el-timeline>
    </el-dialog>
  </div>
</template>

<script>
import cityData from './citydata.js'
export default {
  data () {
    return {
      queryData: {
        query: '',
        pagenum: 1,
        pagesize: 10
      },
      orders: [],
      total: 0,
      editAddressDialogVisible: false,
      form: {
        cityValue: []
      },
      cityData,
      expressProgressDialogVisible: false,
      expressList: []
    }
  },

  created () {
    this.getOders()
  },

  methods: {
    async getOders () {
      const { data: res } = await this.$axios.get('orders', {
        params: this.queryData
      })
      if (res.meta.status !== 200) return this.$message.error('获取数据失败')
      this.orders = res.data.goods
      this.total = res.data.total
    },
    cascaderHandleChange () {
      console.log('this.form.cityData')
    },
    async showExpressProgress () {
      this.expressProgressDialogVisible = true
      const { data: res } = await this.$axios.get('http://localhost:8080/api/express')
      console.log(res)
      if (res.meta.status !== 200) return this.$message.error('获取数据失败')
      this.expressList = res.data
    }
  }
}
</script>

<style scoped lang='less'>
</style>
